#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
    int n = 0;
    scanf("%d", &n);
    char c[1001] = { 0 };

        gets(c);
        int l = strlen(c);
        int j = 0;

        for (int i = 0; i < l-3; i++)
        {
            j = i;
            while (c[j] == 0)
            {
                if (j < l - 1)
                    j++;
                else
                    break;
            }
            j--;
            if (c[i] != c[j])
            {
                i = j - 1;
            }
            else
            {
                while (c[j] == 0)
                {
                    if (j < l - 1)
                        j++;
                    else
                        break;
                }
                j--;
                if (c[i] == c[j])
                {
                    c[j] = 0;
                    i--;
                }
                else
                {
                    int ret = j;
                    while (c[ret] == 0)
                    {
                        if (ret < l - 1)
                            ret++;
                        else
                            break;
                    }
                    ret--;
                    if (c[ret] == c[j])
                    {
                        c[j] = 0;
                        i--;
                    }
                    else
                    {
                        i = ret - 1;
                    }
                }
            }

        }

        for (int i = 0; i < l; i++)
        {
            if (c[i] != 0)
                printf("%c", c[i]);
        }


    
    return 0;
}